package com.lcx.plugin.neteaseCloud.component.toolwindow.login.phone;

import com.lcx.plugin.neteaseCloud.component.toolwindow.login.AbstractPhoneDialogWrapper;
import com.lcx.plugin.neteaseCloud.enums.LoginTypeEnum;
import com.lcx.plugin.neteaseCloud.music.DataCenter;
import com.lcx.plugin.neteaseCloud.music.UserInfo;

import java.util.Objects;

/**
 * @author wengyongcheng
 * @since 2020/3/2 10:36 下午
 */
public class PhoneLoginDialogWrapper extends AbstractPhoneDialogWrapper {

    public PhoneLoginDialogWrapper() {
        textField.setText("");
    }

    @Override
    public String getHead() {
        return "登录 (2/3)";
    }

    @Override
    public String getInfoMsg() {
        return "请输入手机号和国家码";
    }

    @Override
    public String getBottomMsg() {
        return "请输入手机号(按\"Enter\"以确认输入或按\"Esc\"以取消)";
    }

    @Override
    public void nextStep(String text, String countryCode) {
        DataCenter.countryCode = countryCode;
        DataCenter.accountNumber = text;
        // 判断是密码登录还是验证码登录
        if (Objects.equals(DataCenter.loginType, LoginTypeEnum.PHONE_NUMBER.getCode())) {
            // 手机号登录
            new PhonePwdDialogWrapper().show();
        } else {
            // 验证码登录
            // 发送手机验证码
            UserInfo.sendPhoneCode(text);
            new PhoneCodeDialogWrapper().show();
        }
    }

}
